<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>泰然首页-[转载]从零开始学习OpenGL ES之三 – 透视 -  Powered by Discuz!</title>

<meta name="keywords" content="[转载]从零开始学习OpenGL ES之三 – 透视" />
<meta name="description" content="图形图像, 编程,编程, OpenGL ES, 教程,OpenGL ES 3D " />
<meta name="generator" content="Discuz! X3.2" />
<meta name="author" content="Discuz! Team and Comsenz UI Team" />
<meta name="copyright" content="2001-2013 Comsenz Inc." />
<meta name="MSSmartTagsPreventParsing" content="True" />
<meta http-equiv="MSThemeCompatible" content="Yes" />
<base href="http://bbs.tairan.com/" /><link rel="stylesheet" type="text/css" href="data/cache/style_6_common.css?pLa" /><link rel="stylesheet" type="text/css" href="data/cache/style_6_portal_view.css?pLa" /><script type="text/javascript">var STYLEID = '6', STATICURL = 'static/', IMGDIR = 'static/image/common', VERHASH = 'pLa', charset = 'utf-8', discuz_uid = '0', cookiepre = 'Bgbu_2132_', cookiedomain = '', cookiepath = '/', showusercard = '1', attackevasive = '0', disallowfloat = 'newthread', creditnotice = '2|泰然币|,3|大神值|,6|膜拜值|', defaultstyle = '', REPORTURL = 'aHR0cDovL2Jicy50YWlyYW4uY29tL2FydGljbGUtNi0xLmh0bWw=', SITEURL = 'http://bbs.tairan.com/', JSPATH = 'data/cache/', CSSPATH = 'data/cache/style_', DYNAMICURL = '';</script>
<script src="data/cache/common.js?pLa" type="text/javascript"></script>
<meta name="application-name" content="泰然" />
<meta name="msapplication-tooltip" content="泰然" />
<meta name="msapplication-task" content="name=泰然首页;action-uri=http://bbs.tairan.com/portal.php;icon-uri=http://bbs.tairan.com/static/image/common/portal.ico" /><meta name="msapplication-task" content="name=泰然论坛;action-uri=http://bbs.tairan.com/forum.php;icon-uri=http://bbs.tairan.com/static/image/common/bbs.ico" />
<script src="data/cache/portal.js?pLa" type="text/javascript"></script>
</head>

<body id="nv_portal" class="pg_view" onkeydown="if(event.keyCode==27) return false;">
<div id="append_parent"></div><div id="ajaxwaitid"></div>
<div id="toptb" class="cl">
<div class="wp">
<div class="z"><a href="http://bbs.tairan.com/portal.php" >旧版首页</a><a href="http://bbs.tairan.com/"  onclick="addFavorite(this.href, '泰然');return false;">收藏本站</a></div>
<div class="y">
<a id="switchblind" href="javascript:;" onclick="toggleBlind(this)" title="开启辅助访问" class="switchblind">开启辅助访问</a>
</div>
</div>
</div>

<div id="qmenu_menu" class="p_pop blk" style="display: none;">
<div class="ptm pbw hm">
请 <a href="javascript:;" class="xi2" onclick="lsSubmit()"><strong>登录</strong></a> 后使用快捷导航<br />没有帐号？<a href="member.php?mod=register" class="xi2 xw1">注册泰然</a>
</div>
<div id="fjump_menu" class="btda"></div></div><div id="hd">
<div class="wp">
<div class="hdc cl"><h2><a href="./" title="泰然"><img src="template/simple_mini/image/logo.png" alt="泰然" border="0" /></a></h2><script src="data/cache/logging.js?pLa" type="text/javascript"></script>
<form method="post" autocomplete="off" id="lsform" action="member.php?mod=logging&amp;action=login&amp;loginsubmit=yes&amp;infloat=yes&amp;lssubmit=yes" onsubmit="return lsSubmit();">
<div class="fastlg cl">
<span id="return_ls" style="display:none"></span>
<div class="y pns">
<table cellspacing="0" cellpadding="0">
<tr>
<td>
<span class="ftid">
<select name="fastloginfield" id="ls_fastloginfield" width="40" tabindex="900">
<option value="username">用户名</option>
<option value="email">Email</option>
</select>
</span>
<script type="text/javascript">simulateSelect('ls_fastloginfield')</script>
</td>
<td><input type="text" name="username" id="ls_username" autocomplete="off" class="px vm" tabindex="901" /></td>
<td class="fastlg_l"><label for="ls_cookietime"><input type="checkbox" name="cookietime" id="ls_cookietime" class="pc" value="2592000" tabindex="903" />自动登录</label></td>
<td>&nbsp;<a href="javascript:;" onclick="showWindow('login', 'member.php?mod=logging&action=login&viewlostpw=1')">找回密码</a></td>
</tr>
<tr>
<td><label for="ls_password" class="z psw_w">密码</label></td>
<td><input type="password" name="password" id="ls_password" class="px vm" autocomplete="off" tabindex="902" /></td>
<td class="fastlg_l"><button type="submit" class="pn vm" tabindex="904" style="width: 75px;"><em>登录</em></button></td>
<td>&nbsp;<a href="member.php?mod=register" class="xi2 xw1">注册泰然</a></td>
</tr>
</table>
<input type="hidden" name="quickforward" value="yes" />
<input type="hidden" name="handlekey" value="ls" />
</div>

<div class="fastlg_fm y" style="margin-right: 10px; padding-right: 10px">
<p><a href="http://bbs.tairan.com/connect.php?mod=login&op=init&referer=portal.php%3Fmod%3Dview%26aid%3D6%26page%3D1&statfrom=login_simple"><img src="static/image/common/qq_login.gif" class="vm" alt="QQ登录" /></a></p>
<p class="hm xg1" style="padding-top: 2px;">只需一步，快速开始</p>
</div>
</div>
</form>

</div>

<div id="nv">
<a href="javascript:;" id="qmenu" onmouseover="delayShow(this, function () {showMenu({'ctrlid':'qmenu','pos':'34!','ctrlclass':'a','duration':2});showForummenu(0);})">快捷导航</a>
<ul><li id="mn_N0e4a" ><a href="http://www.tairan.com/" hidefocus="true"  >泰然首页</a></li><li id="mn_N5d1f" onmouseover="showMenu({'ctrlid':this.id,'ctrlclass':'hover','duration':2})"><a href="http://www.tairan.com/tutorials" hidefocus="true"  >精品教程</a></li><li id="mn_forum" ><a href="forum.php" hidefocus="true" title="BBS"  >泰然论坛<span>BBS</span></a></li><li id="mn_F81" ><a href="http://indie.tairan.com" hidefocus="true"  >独立游戏</a></li><li id="mn_Nf099" ><a href="http://bbs.tairan.com/forum-76-1.html" hidefocus="true"  >游戏源码</a></li><li id="mn_N386f" onmouseover="showMenu({'ctrlid':this.id,'ctrlclass':'hover','duration':2})"><a href="http://www.tairan.com/about/" hidefocus="true"  >泰然团队</a></li><li id="mn_N68fa" ><a href="http://www.tairan.com/engines-download/" hidefocus="true"  >引擎下载</a></li></ul>
</div>
<ul class="p_pop h_pop" id="mn_N5d1f_menu" style="display: none"><li><a href="http://www.tairan.com/archives/category/cocos/quick-cocos2d-x-cocos/" hidefocus="true" >Quick-Cocos2d-x</a></li><li><a href="http://www.tairan.com/archives/category/cocos/cocos2d-x/" hidefocus="true" >Cocos2d-x</a></li><li><a href="http://www.tairan.com/archives/category/iphone-ios/" hidefocus="true" >iOS</a></li><li><a href="http://www.tairan.com/archives/category/opengl-es/" hidefocus="true" >OpenGL ES</a></li></ul><ul class="p_pop h_pop" id="mn_N386f_menu" style="display: none"><li><a href="http://www.tairan.com/skull/" hidefocus="true" >骷髅会</a></li></ul><div class="p_pop h_pop" id="mn_userapp_menu" style="display: none"></div><div id="mu" class="cl">
</div><div id="scbar" class="cl">
<form id="scbar_form" method="post" autocomplete="off" onsubmit="searchFocus($('scbar_txt'))" action="search.php?searchsubmit=yes" target="_blank">
<input type="hidden" name="mod" id="scbar_mod" value="search" />
<input type="hidden" name="formhash" value="5ede86ec" />
<input type="hidden" name="srchtype" value="title" />
<input type="hidden" name="srhfid" value="0" />
<input type="hidden" name="srhlocality" value="portal::view" />
<table cellspacing="0" cellpadding="0">
<tr>
<td class="scbar_icon_td"></td>
<td class="scbar_txt_td"><input type="text" name="srchtxt" id="scbar_txt" value="请输入搜索内容" autocomplete="off" x-webkit-speech speech /></td>
<td class="scbar_type_td"><a href="javascript:;" id="scbar_type" class="xg1" onclick="showMenu(this.id)" hidefocus="true">搜索</a></td>
<td class="scbar_btn_td"><button type="submit" name="searchsubmit" id="scbar_btn" sc="1" class="pn pnc" value="true"><strong class="xi2">搜索</strong></button></td>
<td class="scbar_hot_td">
<div id="scbar_hot">
<strong class="xw1">热搜: </strong>

<a href="search.php?mod=forum&amp;srchtxt=OpenGL&amp;formhash=5ede86ec&amp;searchsubmit=true&amp;source=hotsearch" target="_blank" class="xi2" sc="1">OpenGL</a>



<a href="search.php?mod=forum&amp;srchtxt=Cocos2d&amp;formhash=5ede86ec&amp;searchsubmit=true&amp;source=hotsearch" target="_blank" class="xi2" sc="1">Cocos2d</a>



<a href="search.php?mod=forum&amp;srchtxt=%E6%B3%B0%E7%84%B6%E6%95%99%E7%A8%8B&amp;formhash=5ede86ec&amp;searchsubmit=true&amp;source=hotsearch" target="_blank" class="xi2" sc="1">泰然教程</a>

</div>
</td>
</tr>
</table>
</form>
</div>
<ul id="scbar_type_menu" class="p_pop" style="display: none;"><li><a href="javascript:;" rel="forum" class="curtype">帖子</a></li><li><a href="javascript:;" rel="user">用户</a></li></ul>
<script type="text/javascript">
initSearchmenu('scbar', '');
</script>
</div>
</div>


<div id="wp" class="wp">
<!--[name]!portalcategory_viewtplname![/name]-->

<script src="data/cache/forum_viewthread.js?pLa" type="text/javascript"></script>
<script type="text/javascript">zoomstatus = parseInt(1), imagemaxwidth = '600', aimgcount = new Array();</script>
<div id="pt" class="bm cl">
<div class="z">
<a href="./" class="nvhm" title="首页">泰然</a> <em>&rsaquo;</em>
<a href="portal.php">泰然首页</a> <em>&rsaquo;</em><a href="http://bbs.tairan.com/portal.php?mod=list&catid=1">openGL ES教程</a><em>&rsaquo;</em>
<a href="http://bbs.tairan.com/portal.php?mod=list&catid=3">从零开始学习OpenGL ES</a> <em>&rsaquo;</em>
查看内容
</div>
</div>

<style id="diy_style" type="text/css"></style>
<div class="wp">
<!--[diy=diy1]--><div id="diy1" class="area"></div><!--[/diy]-->
</div>
<div id="ct" class="ct2 wp cl">
<div class="mn">
<div class="bm vw">
<div class="h hm">
<h1 class="ph">[转载]从零开始学习OpenGL ES之三 – 透视 </h1>
<p class="xg1">
2011-9-14 23:32<span class="pipe">|</span>
发布者: <a href="space-uid-2.html">Iven</a><span class="pipe">|</span>
查看: <em id="_viewnum">12792</em><span class="pipe">|</span>
评论: <a href="portal.php?mod=comment&id=6&idtype=aid" title="查看全部评论"><em id="_commentnum">20</em></a></p>
</div>

<!--[diy=diysummarytop]--><div id="diysummarytop" class="area"></div><!--[/diy]-->

<div class="s"><div><strong>摘要</strong>: 图形图像, 编程,编程, OpenGL ES, 教程,OpenGL ES 3D</div></div>
<!--[diy=diysummarybottom]--><div id="diysummarybottom" class="area"></div><!--[/diy]-->

<div class="d">

<!--[diy=diycontenttop]--><div id="diycontenttop" class="area"></div><!--[/diy]-->

<table cellpadding="0" cellspacing="0" class="vwtb"><tr><td id="article_content"><span class="Apple-style-span" style="color: rgb(36, 32, 32); font-family: 'Microsoft YaHei', Helvetica, Arial; line-height: 28px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">现在你已经知道OpenGL是怎样绘图的了，让我们回头谈谈一个很重要的概念：OpenGL<strong>视口（viewport）</strong>。 许多人对3D编程还很陌生，那些使用过像Maya, Blender, 或 Lightwave之类3D图形程序的人都试图在OpenGL虚拟世界中找到“摄像机”。但OpenGL并不存在这样的东西。它所有的是在3D空间中定义可见的物体。虚拟世界是没有边界的，但计算机不可能处理无限的空间，所以OpenGL需要我们定义一个可以被观察者看到的空间。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">如果我们从大部分3D程序具有的摄像机对象的角度出发来考虑，视口端点的中心就是摄像机。也就是观察者站的位置。它是一个观察虚拟世界的虚拟窗口。观察者可见的空间有一定限制。她看不见她身后的东西。她也看不见视角之外的东西。而且她还不能看见太远的东西。可以认为视口是通过“观察者可见”参数所确定的形状。很简单，对吗？</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">不幸的是，并非如此。要解释原因，我们首先需要讨论的是在OpenGL ES中具有的两种不同的视口类型：正交和透视。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span id="more-580"></span></p><h2>正交和透视</h2><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">为更好地理解，我们先看看铁路轨道，好吗？要正常工作，铁路的两条铁轨之间必须具有固定的距离。其固定的距离是由铁轨根据承载什么样的火车而决定。重要的是铁轨（以及火车的轮子）必须具有相同的距离。如果不是这样，火车根本不可能运行。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">如果我们从上方观察铁轨，这个事实很明显。</p><div style="text-align: center; "><p><a href="data/attachment/portal/201109/14/232944bsbb8ecqcl8r8sbc.jpg" target="_blank"><img src="data/attachment/portal/201109/14/232944bsbb8ecqcl8r8sbc.jpg"></a></p></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">但是如果你站在铁轨上向下观察会怎么样。不要说“你会被火车撞”，我假设你会足够聪明，会在没有火车开动时进行观察。</p><div style="text-align: center; "><p><a href="data/attachment/portal/201109/14/233036fiz90qtk0ofbiio0.jpg" target="_blank"><img src="data/attachment/portal/201109/14/233036fiz90qtk0ofbiio0.jpg"></a></p></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">是的，铁轨看上去越远与靠近。感谢二年级美术老师，可能你已经知道这就是所谓<strong>透视（perspective</strong>）。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">OpenGL可以设定的视口中的一种就是使用透视。当你这样设置视口时，物体会随着移远而越来越小，视线会在物体移离观察者时最终交汇。这是对真实视觉的模拟；人们就是以这种方式观察世界的。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">另一种看设置的视口称为<strong>正交（orthogonal）</strong>&nbsp;视口。这种类型的视口，视线永远不会交汇而且物体不会改变其大小。没有透视效果。对于CAD程序以及其他各种目的是十分方便的，但因为它不像人们眼睛观察的方式所以看上去是不真实的，通常也不是你所希望的。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">对于正交视口，你看将摄像机置于铁轨上，但这些铁轨永远不会交汇。它们将随着远离你的视线而继续保持等距。即使你定义了一个无限大的视口（OpenGL ES并不支持），这些线仍保持等距。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">正交视口的优点是容易定义。因为线永不交汇，你只需定义一个像箱子一样的3D空间，像这样：</p><div style="text-align: center; "><p><a href="data/attachment/portal/201109/14/232949axqyczcioqoqnqlg.jpg" target="_blank"><img src="data/attachment/portal/201109/14/232949axqyczcioqoqnqlg.jpg"></a></p></div><h2>设置正交视口</h2><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">在使用<span style="font-family: monospace; ">glViewport()函数定义视口前，你可以通过</span><span style="font-family: monospace; ">glOrthof()</span><span style="font-family: monospace; ">通知</span>OpenGL ES你希望使用正交视口。下面是一个简单的例子：</p><pre><span>    <span>CGRect</span> rect = view.bounds;
<span><span>    </span><span>glOrthof</span><span>(-<span>1.0</span>,                                          <span><span>//</span> Left
</span>              <span>1.0</span>,                                          <span><span>//</span> Right
</span>             -<span>1.0</span> / (rect.size.width / rect.size.height)</span>,   <span><span>//</span> Bottom</span>
              1.0 / <span>(rect.size.width / rect.size.height)</span>,   <span><span>//</span> Top</span>
              0.01,                                         <span><span>//</span> Near</span>
              10000.0);</span>                                     <span><span>//</span> Far
</span><span><span>    </span><span>glViewport</span><span>(<span>0</span>, <span>0</span>, rect.size.width, rect.size.height)</span>;</span></span></pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">这不难理解。首先我们获取视窗的尺寸。然后设定视口空间的宽度为两个单位，沿x轴从 -1.0 到 +1.0。很容易吧。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">接着怎样设定底部和顶部？我们希望我们定义空间的X和Y坐标的宽高比与视窗的宽高比（也就是iPhone全屏时的宽高比）一样。由于iPhone的宽度与高度不同，我们需要确保视口的x和y坐标不同，但遵循一样的比例。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">之后，我们定义了&nbsp;<span style="font-family: monospace; ">near（远）和</span>&nbsp;<span style="font-family: monospace; ">far（近）</span>&nbsp;范围来描述观察的深度。&nbsp;<span style="font-family: monospace; ">near</span>&nbsp;参数说明了视口开始的位置。如果我们站在原点处，视口就位于我们的面前，所以习惯上使用&nbsp;<span style="font-family: monospace; ">.01</span>&nbsp;或&nbsp;<span style="font-family: monospace; ">.001</span>&nbsp;作为正交视口的起点。这使得视口处于原点“前方”一点点。<span style="font-family: monospace; ">far</span>&nbsp;可以根据你程序的需要来设定。如果你程序中的物体永远不会远过20个单位，那么你不需要将&nbsp;<span style="font-family: monospace; ">far设置为</span>20,000 个单位。具体的数字随程序的不同而不同。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">调用&nbsp;<span style="font-family: monospace; ">glOrthof()之后，</span>我们使用视窗矩形来调用&nbsp;<span style="font-family: monospace; ">glViewport()。</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: monospace; ">这是比较简单的情况。<br></span></p><h2>设置透视视口</h2><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">另一种情况就不那么简单，这里是原因。如果物体随着远离观察者而变小，那么它和你定义的可见空间的形状有什么关系。随着视线越来越远，你可以看到更广阔的世界，所以如果你使用透视，那么你定义的空间将不是一个立方体。是的，当使用透视时可见空间的形状称为<a href="http://s2.97proxy.com:9999/browse.php?u=e4d94f27966665Oi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL0ZydXN0dW0%3D&amp;b=1" target="_blank" style="text-decoration: none; color: rgb(63, 63, 175); ">锥台（frustum）</a>。 是的，我知道，奇怪的名字。但却是真实的。我们的锥台看上去像这样：</p><div style="text-align: center; "><p><a href="data/attachment/portal/201109/14/2329512ddhekkfevviq8ze.jpg" target="_blank"><img src="data/attachment/portal/201109/14/2329512ddhekkfevviq8ze.jpg"></a></p></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">请注意当我们离视口越来越远时（换句话说，当z值减小时），观察体的x和y坐标都会越来越大。</p><p style="margin: 0px; padding: 0px;">要设置透视视口，我们不使用&nbsp;<span style="font-family: monospace; ">glOrthof()，</span>我们使用一个不同的函数&nbsp;<span style="font-family: monospace; ">glFrustumf()</span>。此函数使用同样的六个参数。很容易理解，但我们应该怎样确定传递给&nbsp;<span style="font-family: monospace; ">glFrustumf()的参数</span>？<span style="font-family: monospace;"><br></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="font-family: monospace;">near</span> 和 <span style="font-family: monospace;">far</span> 容易理解。你可以同样方式理解它们。<span style="font-family: monospace;">near 使用类似 </span><span style="font-family: monospace;">.001的数值，然后根据不同程序的需要确定 </span><span style="font-family: monospace;">far</span> 值。</p></span><span class="Apple-style-span" style="color: rgb(36, 32, 32); font-family: 'Microsoft YaHei', Helvetica, Arial; line-height: 28px; ">但是&nbsp;<span style="font-family: monospace; ">left</span>,&nbsp;<span style="font-family: monospace; ">right</span>,&nbsp;<span style="font-family: monospace; ">bottom</span>, 和&nbsp;<span style="font-family: monospace; ">top 呢？</span>&nbsp;为设置这些值，我们需要一点点数学计算。</span><span class="Apple-style-span" style="color: rgb(36, 32, 32); font-family: 'Microsoft YaHei', Helvetica, Arial; line-height: 28px; "></span><span class="Apple-style-span" style="color: rgb(36, 32, 32); line-height: 28px; "><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">要计算锥台，我们首先要理解<strong>视野（field of vision</strong>）的概念，它是由两个角度定义的。让我们这样做：伸出双臂手掌合拢伸向前方。你的手臂现在指向你自己锥台的z轴，对吗？好，现在慢慢分开你的双臂。由于在你双臂展开时肩膀保持不动，你定义了一个逐渐增大的角度。这就是用于定义观察锥台的两个角度之一。它定义了视野的宽度。另一个角度的定义原理一样，只是这次你向上下展开你的双臂。如果你的双手间距只有三英寸，那么x角度将非常小。</p><div style="font-family: 'Microsoft YaHei', Helvetica, Arial; text-align: center; "><p><a href="data/attachment/portal/201109/14/232952oh8qhp66qm66mxom.jpg" target="_blank"><img src="data/attachment/portal/201109/14/232952oh8qhp66qm66mxom.jpg"></a></p></div><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">这称为<em>窄视野。</em></p><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">如果你双手分开两英尺，视野的宽度变得很大。</p><div style="font-family: 'Microsoft YaHei', Helvetica, Arial; text-align: center; "><p><a href="data/attachment/portal/201109/14/2330421odcdmbzz8tmfcrd.jpg" target="_blank"><img src="data/attachment/portal/201109/14/2330421odcdmbzz8tmfcrd.jpg"></a></p></div><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">这就是所谓<em>&nbsp;宽视角（广角）。</em></p><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">如果用摄影术语描述，你可将视野当作虚拟相机的虚拟光圈的焦距。窄视野很像摄远镜头，它造就了一个缓慢增长的长锥台。宽视角就像广角镜，它造就了一个增长很快的锥台。</p><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">我们选择一个中间值，例如45°。 使用这个值，我们怎样计算我们的观察锥台？我们先看下两个角度中的一个。想象一下，从顶部看锥台是什么样子。下面是示意图：</p><div style="font-family: 'Microsoft YaHei', Helvetica, Arial; text-align: center; "><p><a href="data/attachment/portal/201109/14/232956c2nh4v264knih64h.png" target="_blank"><img src="data/attachment/portal/201109/14/232956c2nh4v264knih64h.png"></a></p></div><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">从上向下看，它就像一个砍掉一个点的三角形。但对我们而言，它已经足够接近一个三角形。你还记得三角课上的正切吗？正切函数定义为直角对边与相邻边的比率。</p><div style="font-family: 'Microsoft YaHei', Helvetica, Arial; text-align: center; "><p><a href="data/attachment/portal/201109/14/232958oo4tbcoi7mcmd7oo.png" target="_blank"><img src="data/attachment/portal/201109/14/232958oo4tbcoi7mcmd7oo.png"></a></p></div><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">但是，我们没有直角，是吗？</p><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">实际上，我们有两个直角… 如果我们沿z轴向下画一条直线的话：</p><div style="font-family: 'Microsoft YaHei', Helvetica, Arial; text-align: center; "><p><a href="data/attachment/portal/201109/14/233002vq95zjerlzd29viq.png" target="_blank"><img src="data/attachment/portal/201109/14/233002vq95zjerlzd29viq.png"></a></p></div><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">中心虚线就是两个直角的“相邻边”。所以，锥台远端宽度的一半就是视野角度正切的一半。如果我们将此值乘以&nbsp;<span style="font-family: monospace; ">near值，就可以得到&nbsp;</span><span style="font-family: monospace; ">right值。</span><span style="font-family: monospace; ">right值取反就是&nbsp;</span><span style="font-family: monospace; ">left</span>。</p><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">我们希望视野具有与屏幕一样的长宽比，所以按照&nbsp;<span style="font-family: monospace; ">glOrthof()中相同的方法（将&nbsp;</span><span style="font-family: monospace; ">right 乘以屏幕的长宽比）</span><span style="font-family: monospace; ">来</span><span style="font-family: monospace; ">计算</span><span style="font-family: monospace; ">top 和 bottom 值。代码如下：</span></p><pre style="font-family: 'Microsoft YaHei', Helvetica, Arial; "><span><span>CGRect</span> rect = view.bounds;
GLfloat size = .01 *<span><span> </span><span>tanf</span><span>(DEGREES_TO_RADIANS(<span>45.0</span>)</span> / 2.0);</span> 

<span><span>glFrustumf</span><span>(-size,                                           <span><span>//</span> Left
</span>            size,                                           <span><span>//</span> Right
</span>           -size / (rect.size.width / rect.size.height)</span>,    <span><span>//</span> Bottom</span>
            size / <span>(rect.size.width / rect.size.height)</span>,    <span><span>//</span> Top</span>
            .01,                                          <span><span>//</span> Near</span>
            1000.0);</span>                                          <span><span>//</span> Far</span></span></pre><blockquote style="font-family: 'Microsoft YaHei', Helvetica, Arial; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(222, 222, 222); padding-top: 15px; padding-right: 15px; padding-bottom: 15px; padding-left: 15px; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strong>注意：</strong>关于&nbsp;<span style="font-family: monospace; ">glFrustum() 怎样使用传递的参数计算锥台的形状将在我们讨论矩阵时讨论。现在，我们暂且相信计算是正确的，好吗？</span></p></blockquote><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">让我们运用到程序中。我修改了上篇文章中最终的&nbsp;<span style="font-family: monospace; ">drawView:方法，我们将沿z轴向下显示了三十个二十面体。下面是新的</span><span style="font-family: monospace; ">&nbsp;drawView:</span>&nbsp;方法：</p><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">- (<span>void</span>)drawView:(GLView*)view;</p><pre style="font-family: 'Microsoft YaHei', Helvetica, Arial; "><span><span>{
    <span>static</span> GLfloat rot = <span>0.0</span>;

    <span>static</span> <span>const</span> Vertex3D vertices<span><span>[</span><span>]</span></span>= <span>{
        <span>{<span>0</span>, -<span>0.525731</span>, <span>0.850651</span>}</span>,             <span><span>//</span> vertices[0]
</span>        <span>{<span>0.850651</span>, <span>0</span>, <span>0.525731</span>}</span>,              <span><span>//</span> vertices[1]
</span>        <span>{<span>0.850651</span>, <span>0</span>, -<span>0.525731</span>}</span>,             <span><span>//</span> vertices[2]
</span>        <span>{-<span>0.850651</span>, <span>0</span>, -<span>0.525731</span>}</span>,            <span><span>//</span> vertices[3]
</span>        <span>{-<span>0.850651</span>, <span>0</span>, <span>0.525731</span>}</span>,             <span><span>//</span> vertices[4]
</span>        <span>{-<span>0.525731</span>, <span>0.850651</span>, <span>0</span>}</span>,             <span><span>//</span> vertices[5]
</span>        <span>{<span>0.525731</span>, <span>0.850651</span>, <span>0</span>}</span>,              <span><span>//</span> vertices[6]
</span>        <span>{<span>0.525731</span>, -<span>0.850651</span>, <span>0</span>}</span>,             <span><span>//</span> vertices[7]
</span>        <span>{-<span>0.525731</span>, -<span>0.850651</span>, <span>0</span>}</span>,            <span><span>//</span> vertices[8]
</span>        <span>{<span>0</span>, -<span>0.525731</span>, -<span>0.850651</span>}</span>,            <span><span>//</span> vertices[9]
</span>        <span>{<span>0</span>, <span>0.525731</span>, -<span>0.850651</span>}</span>,             <span><span>//</span> vertices[10]
</span>        <span>{<span>0</span>, <span>0.525731</span>, <span>0.850651</span>}</span>               <span><span>//</span> vertices[11]
</span>    }</span>;

    <span>static</span> <span>const</span> Color3D colors<span><span>[</span><span>]</span></span> = <span>{
        <span>{<span>1.0</span>, <span>0.0</span>, <span>0.0</span>, <span>1.0</span>}</span>,
        <span>{<span>1.0</span>, <span>0.5</span>, <span>0.0</span>, <span>1.0</span>}</span>,
        <span>{<span>1.0</span>, <span>1.0</span>, <span>0.0</span>, <span>1.0</span>}</span>,
        <span>{<span>0.5</span>, <span>1.0</span>, <span>0.0</span>, <span>1.0</span>}</span>,
        <span>{<span>0.0</span>, <span>1.0</span>, <span>0.0</span>, <span>1.0</span>}</span>,
        <span>{<span>0.0</span>, <span>1.0</span>, <span>0.5</span>, <span>1.0</span>}</span>,
        <span>{<span>0.0</span>, <span>1.0</span>, <span>1.0</span>, <span>1.0</span>}</span>,
        <span>{<span>0.0</span>, <span>0.5</span>, <span>1.0</span>, <span>1.0</span>}</span>,
        <span>{<span>0.0</span>, <span>0.0</span>, <span>1.0</span>, <span>1.0</span>}</span>,
        <span>{<span>0.5</span>, <span>0.0</span>, <span>1.0</span>, <span>1.0</span>}</span>,
        <span>{<span>1.0</span>, <span>0.0</span>, <span>1.0</span>, <span>1.0</span>}</span>,
        <span>{<span>1.0</span>, <span>0.0</span>, <span>0.5</span>, <span>1.0</span>}</span>
    }</span>;

    <span>static</span> <span>const</span> GLubyte icosahedronFaces<span><span>[</span><span>]</span></span> = <span>{
        <span>1</span>, <span>2</span>, <span>6</span>,
        <span>1</span>, <span>7</span>, <span>2</span>,
        <span>3</span>, <span>4</span>, <span>5</span>,
        <span>4</span>, <span>3</span>, <span>8</span>,
        <span>6</span>, <span>5</span>, <span>11</span>,
        <span>5</span>, <span>6</span>, <span>10</span>,
        <span>9</span>, <span>10</span>, <span>2</span>,
        <span>10</span>, <span>9</span>, <span>3</span>,
        <span>7</span>, <span>8</span>, <span>9</span>,
        <span>8</span>, <span>7</span>, <span>0</span>,
        <span>11</span>, <span>0</span>, <span>1</span>,
        <span>0</span>, <span>11</span>, <span>4</span>,
        <span>6</span>, <span>2</span>, <span>10</span>,
        <span>1</span>, <span>6</span>, <span>11</span>,
        <span>3</span>, <span>5</span>, <span>10</span>,
        <span>5</span>, <span>4</span>, <span>11</span>,
        <span>2</span>, <span>7</span>, <span>9</span>,
        <span>7</span>, <span>1</span>, <span>0</span>,
        <span>3</span>, <span>9</span>, <span>8</span>,
        <span>4</span>, <span>8</span>, <span>0</span>,
    }</span>;

<span><span>    </span><span>glLoadIdentity</span>(</span>);
<span><span>    </span><span>glClearColor</span>(</span><span>0.7</span>, <span>0.7</span>, <span>0.7</span>, <span>1.0</span>);
<span><span>    </span><span>glClear</span>(</span>GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
<span><span>    </span><span>glEnableClientState</span>(</span>GL_VERTEX_ARRAY);
<span><span>    </span><span>glEnableClientState</span>(</span>GL_COLOR_ARRAY);
<span><span>    </span><span>glVertexPointer</span>(</span><span>3</span>, GL_FLOAT, <span>0</span>, vertices);
<span><span>    </span><span>glColorPointer</span>(</span><span>4</span>, GL_FLOAT, <span>0</span>, colors);
    <span>for</span><span> <span>(</span></span><span>int</span> i = <span>1</span>; i &lt;= <span>30</span>; i++)
    <span>{
<span><span>        </span><span>glLoadIdentity</span>(</span>);
<span><span>        </span><span>glTranslatef</span>(</span><span>0.0f</span>,-<span>1.5</span>,-<span>3.0f</span> * (GLfloat)i);
<span><span>        </span><span>glRotatef</span>(</span>rot, <span>1.0</span>, <span>1.0</span>, <span>1.0</span>);
<span><span>        </span><span>glDrawElements</span>(</span>GL_TRIANGLES, <span>60</span>, GL_UNSIGNED_BYTE, icosahedronFaces);
    }</span>
<span><span>    </span><span>glDisableClientState</span>(</span>GL_VERTEX_ARRAY);
<span><span>    </span><span>glDisableClientState</span>(</span>GL_COLOR_ARRAY);
    <span>static</span> <span>NSTimeInterval</span> lastDrawTime;
    <span>if</span><span> <span>(</span></span>lastDrawTime)
    <span>{
        <span>NSTimeInterval</span> timeSinceLastDraw = <span><span>[</span><span>NSDate</span> <span><span>timeIntervalSinceReferenceDate</span></span><span>]</span></span> - lastDrawTime;
        rot+=<span>50</span> * timeSinceLastDraw;
    }</span>
    lastDrawTime = <span><span>[</span><span>NSDate</span> <span><span>timeIntervalSinceReferenceDate</span></span><span>]</span></span>;
}</span></span></pre><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">如果你把上述代码加入<a href="http://www.iphone-geek.cn/wp-content/uploads/2009/12/Empty_OpenGL_ES_Application.zip" style="text-decoration: none; color: rgb(63, 63, 175); ">OpenGL Xcode项目模板</a>&nbsp;项目中（它使用<span style="font-family: monospace; ">glFrustumf()设置了一个具有</span>45°视野的透视视口），你将看到下面图形：</p><div style="font-family: 'Microsoft YaHei', Helvetica, Arial; text-align: center; "><p><a href="data/attachment/portal/201109/14/233005kyk1zk1gt6fn6ity.jpg" target="_blank"><img src="data/attachment/portal/201109/14/233005kyk1zk1gt6fn6ity.jpg"></a></p></div><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">很好。随着几何体远离你，它们会变得越来越小，正像火车铁轨一样。</p><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">如果你只是将&nbsp;<span style="font-family: monospace; ">glFrustumf()改为</span>&nbsp;<span style="font-family: monospace; ">glOrthof()，看上去就完全不同了：</span></p><div style="font-family: 'Microsoft YaHei', Helvetica, Arial; text-align: center; "><p><a href="data/attachment/portal/201109/14/233008p6dfh97c242dfo24.jpg" target="_blank"><img src="data/attachment/portal/201109/14/233008p6dfh97c242dfo24.jpg"></a></p></div><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">没有透视，第一个二十面体后面的二十九个二十面体完全被第一个挡住了。因为没有透视，后面的各几何体的形状完全取决于其前方的物体。</p><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">好了，这是一个很沉闷的主题，事实上你现在可以完全忘却三角课学的知识了。只要复制基于视野角度计算锥台的两行代码就好，而且你可能再也不需要记住它的原理了。</p><h2>继续下一次激动人心的冒险旅程…</h2><p style="font-family: 'Microsoft YaHei', Helvetica, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">下一篇文章，我们将为二十面体增加光效，使它看上去更真实。</p><div style="font-family: 'Microsoft YaHei', Helvetica, Arial; text-align: center; "><p><a href="data/attachment/portal/201109/14/233011daakkzryzthz11ki.jpg" target="_blank"><img src="data/attachment/portal/201109/14/233011daakkzryzthz11ki.jpg"></a></p></div></span></td></tr></table>

<!--[diy=diycontentbottom]--><div id="diycontentbottom" class="area"></div><!--[/diy]-->

<script src="data/cache/home.js?pLa" type="text/javascript"></script>
<div id="click_div"><table cellpadding="0" cellspacing="0" class="atd">
<tr><td>
<a href="home.php?mod=spacecp&amp;ac=click&amp;op=add&amp;clickid=1&amp;idtype=aid&amp;id=6&amp;hash=44545086080b72e6eb7d0b0c37dd85b4&amp;handlekey=clickhandle" id="click_aid_6_1" onclick="showWindow(this.id, this.href);doane(event);">
<div class="atdc">
<div class="ac1" style="height:50px;">
<em>27</em>
</div>
</div>
<img src="static/image/click/xianhua.gif" alt="" /><br />鲜花</a>
</td>
<td>
<a href="home.php?mod=spacecp&amp;ac=click&amp;op=add&amp;clickid=2&amp;idtype=aid&amp;id=6&amp;hash=44545086080b72e6eb7d0b0c37dd85b4&amp;handlekey=clickhandle" id="click_aid_6_2" onclick="showWindow(this.id, this.href);doane(event);">
<div class="atdc">
<div class="ac4" style="height:5px;">
<em>3</em>
</div>
</div>
<img src="static/image/click/woshou.gif" alt="" /><br />握手</a>
</td>
<td>
<a href="home.php?mod=spacecp&amp;ac=click&amp;op=add&amp;clickid=3&amp;idtype=aid&amp;id=6&amp;hash=44545086080b72e6eb7d0b0c37dd85b4&amp;handlekey=clickhandle" id="click_aid_6_3" onclick="showWindow(this.id, this.href);doane(event);">
<img src="static/image/click/leiren.gif" alt="" /><br />雷人</a>
</td>
<td>
<a href="home.php?mod=spacecp&amp;ac=click&amp;op=add&amp;clickid=4&amp;idtype=aid&amp;id=6&amp;hash=44545086080b72e6eb7d0b0c37dd85b4&amp;handlekey=clickhandle" id="click_aid_6_4" onclick="showWindow(this.id, this.href);doane(event);">
<img src="static/image/click/luguo.gif" alt="" /><br />路过</a>
</td>
<td>
<a href="home.php?mod=spacecp&amp;ac=click&amp;op=add&amp;clickid=5&amp;idtype=aid&amp;id=6&amp;hash=44545086080b72e6eb7d0b0c37dd85b4&amp;handlekey=clickhandle" id="click_aid_6_5" onclick="showWindow(this.id, this.href);doane(event);">
<img src="static/image/click/jidan.gif" alt="" /><br />鸡蛋</a>
</td>
</tr>
</table>
<script type="text/javascript">
function errorhandle_clickhandle(message, values) {
if(values['id']) {
showCreditPrompt();
show_click(values['idtype'], values['id'], values['clickid']);
}
}
</script>

<h3 class="mbm xs1">
刚表态过的朋友 (<a href="javascript:;" onclick="show_click('aid', '6', '5')">30 人</a>)
</h3>
<div id="trace_div" class="xs1">
<ul id="trace_ul" class="ml mls cl"><li>
<div class="avt"><a href="space-uid-16941.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=16941&size=small" /></a></div>
<p><a href="space-uid-16941.html"  title="zhoujie_903" target="_blank">zhoujie_903</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-17969.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=17969&size=small" /></a></div>
<p><a href="space-uid-17969.html"  title="诚锦官" target="_blank">诚锦官</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-8235.html" target="_blank" title="握手"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=8235&size=small" /></a></div>
<p><a href="space-uid-8235.html"  title="々枫々" target="_blank">々枫々</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-10298.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=10298&size=small" /></a></div>
<p><a href="space-uid-10298.html"  title="度娘818" target="_blank">度娘818</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-9547.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=9547&size=small" /></a></div>
<p><a href="space-uid-9547.html"  title="shuiyouren" target="_blank">shuiyouren</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-9540.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=9540&size=small" /></a></div>
<p><a href="space-uid-9540.html"  title="伊然" target="_blank">伊然</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-7838.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=7838&size=small" /></a></div>
<p><a href="space-uid-7838.html"  title="sfyt2000" target="_blank">sfyt2000</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-9199.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=9199&size=small" /></a></div>
<p><a href="space-uid-9199.html"  title="xiupoman" target="_blank">xiupoman</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-1146.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=1146&size=small" /></a></div>
<p><a href="space-uid-1146.html"  title="feng20068" target="_blank">feng20068</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-8770.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=8770&size=small" /></a></div>
<p><a href="space-uid-8770.html"  title="iam_gaowei" target="_blank">iam_gaowei</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-6497.html" target="_blank" title="握手"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=6497&size=small" /></a></div>
<p><a href="space-uid-6497.html"  title="angellrp" target="_blank">angellrp</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-8674.html" target="_blank" title="握手"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=8674&size=small" /></a></div>
<p><a href="space-uid-8674.html"  title="ヅ依楼念风雨" target="_blank">ヅ依楼念风雨</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-7979.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=7979&size=small" /></a></div>
<p><a href="space-uid-7979.html"  title="Dee1990" target="_blank">Dee1990</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-4553.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=4553&size=small" /></a></div>
<p><a href="space-uid-4553.html"  title="killua4869" target="_blank">killua4869</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-7629.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=7629&size=small" /></a></div>
<p><a href="space-uid-7629.html"  title="yjh4866" target="_blank">yjh4866</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-128.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=128&size=small" /></a></div>
<p><a href="space-uid-128.html"  title="dancewnym" target="_blank">dancewnym</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-1403.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=1403&size=small" /></a></div>
<p><a href="space-uid-1403.html"  title="blackair" target="_blank">blackair</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-4800.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=4800&size=small" /></a></div>
<p><a href="space-uid-4800.html"  title="sen" target="_blank">sen</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-736.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=736&size=small" /></a></div>
<p><a href="space-uid-736.html"  title="li4372337494" target="_blank">li4372337494</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-1769.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=1769&size=small" /></a></div>
<p><a href="space-uid-1769.html"  title="fspinach" target="_blank">fspinach</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-1498.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=1498&size=small" /></a></div>
<p><a href="space-uid-1498.html"  title="dingwenjie" target="_blank">dingwenjie</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-219.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=219&size=small" /></a></div>
<p><a href="space-uid-219.html"  title="国松" target="_blank">国松</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-275.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=275&size=small" /></a></div>
<p><a href="space-uid-275.html"  title="286820549" target="_blank">286820549</a></p>
</li>
<li>
<div class="avt"><a href="space-uid-1162.html" target="_blank" title="鲜花"><img src="http://bbs.tairan.com/uc_server/avatar.php?uid=1162&size=small" /></a></div>
<p><a href="space-uid-1162.html"  title="TopWinStudio" target="_blank">TopWinStudio</a></p>
</li>
</ul>
</div>
</div>


<!--[diy=diycontentclickbottom]--><div id="diycontentclickbottom" class="area"></div><!--[/diy]-->

</div>

<div class="o cl ptm pbm">
<a href="home.php?mod=spacecp&amp;ac=favorite&amp;type=article&amp;id=6&amp;handlekey=favoritearticlehk_6" id="a_favorite" onclick="showWindow(this.id, this.href, 'get', 0);" class="oshr ofav">收藏</a>
<a href="misc.php?mod=invite&amp;action=article&amp;id=6" id="a_invite" onclick="showWindow('invite', this.href, 'get', 0);" class="oshr oivt">邀请</a>
</div>
</div>

<!--[diy=diycontentrelatetop]--><div id="diycontentrelatetop" class="area"></div><!--[/diy]-->
<!--[diy=diycontentrelate]--><div id="diycontentrelate" class="area"></div><!--[/diy]-->

<div id="comment" class="bm">
<div class="bm_h cl">
<a href="javascript:;" class="y xi2" onclick="location.href=location.href.replace(/(\#.*)/, '')+'#cform';$('message').focus();return false;">发表评论</a>
<h3>最新评论</h3>
</div>
<div id="comment_ul" class="bm_c"><a name="comment_anchor_407"></a>
<dl id="comment_407_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(407, '6');">引用</a> </span>
<a href="space-uid-8235.html" class="xi2 xw1" c="1">々枫々</a>
<span class="xg1 xw0">2013-9-25 12:01</span>
</dt>
<dd>顶顶顶</dd>
</dl><a name="comment_anchor_339"></a>
<dl id="comment_339_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(339, '6');">引用</a> </span>
<a href="space-uid-6642.html" class="xi2 xw1" c="1">coolbabylch</a>
<span class="xg1 xw0">2012-11-13 18:46</span>
</dt>
<dd>正在学习这个，受教啦<br />
.</dd>
</dl><a name="comment_anchor_332"></a>
<dl id="comment_332_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(332, '6');">引用</a> </span>
<a href="space-uid-8367.html" class="xi2 xw1" c="1">tb706</a>
<span class="xg1 xw0">2012-10-10 10:26</span>
</dt>
<dd>都是高手呀。</dd>
</dl><a name="comment_anchor_310"></a>
<dl id="comment_310_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(310, '6');">引用</a> </span>
<a href="space-uid-6941.html" class="xi2 xw1" c="1">功夫杨</a>
<span class="xg1 xw0">2012-7-3 13:36</span>
</dt>
<dd>顶顶顶</dd>
</dl><a name="comment_anchor_275"></a>
<dl id="comment_275_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(275, '6');">引用</a> </span>
<a href="space-uid-3566.html" class="xi2 xw1" c="1">卫戍区</a>
<span class="xg1 xw0">2012-3-19 20:59</span>
</dt>
<dd>对了，我想问一下OpenGL ES1.0和OpenGL ES2.0区别好像挺大的，这2者各自应用的范围？本人初学，希望大大给点指导！</dd>
</dl><a name="comment_anchor_274"></a>
<dl id="comment_274_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(274, '6');">引用</a> </span>
<a href="space-uid-3566.html" class="xi2 xw1" c="1">卫戍区</a>
<span class="xg1 xw0">2012-3-19 20:57</span>
</dt>
<dd>顶，收获很大</dd>
</dl><a name="comment_anchor_243"></a>
<dl id="comment_243_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(243, '6');">引用</a> </span>
<a href="space-uid-915.html" class="xi2 xw1" c="1">fanxu1218</a>
<span class="xg1 xw0">2012-2-27 10:11</span>
</dt>
<dd>感觉好多的数学问题哦</dd>
</dl><a name="comment_anchor_205"></a>
<dl id="comment_205_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(205, '6');">引用</a> </span>
<a href="space-uid-1903.html" class="xi2 xw1" c="1">myhapi</a>
<span class="xg1 xw0">2012-2-20 11:26</span>
</dt>
<dd>写的很好，</dd>
</dl><a name="comment_anchor_204"></a>
<dl id="comment_204_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(204, '6');">引用</a> </span>
<a href="space-uid-1903.html" class="xi2 xw1" c="1">myhapi</a>
<span class="xg1 xw0">2012-2-20 11:26</span>
</dt>
<dd>正在学习这个，受教啦</dd>
</dl><a name="comment_anchor_199"></a>
<dl id="comment_199_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(199, '6');">引用</a> </span>
<a href="space-uid-2539.html" class="xi2 xw1" c="1">halley</a>
<span class="xg1 xw0">2012-2-19 14:34</span>
</dt>
<dd>wwwwwwwwwwww</dd>
</dl><a name="comment_anchor_185"></a>
<dl id="comment_185_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(185, '6');">引用</a> </span>
<a href="space-uid-736.html" class="xi2 xw1" c="1">li4372337494</a>
<span class="xg1 xw0">2012-2-16 15:28</span>
</dt>
<dd>今天学这节，太感谢了！</dd>
</dl><a name="comment_anchor_171"></a>
<dl id="comment_171_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(171, '6');">引用</a> </span>
<a href="space-uid-2051.html" class="xi2 xw1" c="1">uxkevin</a>
<span class="xg1 xw0">2012-2-6 15:34</span>
</dt>
<dd>学习一下</dd>
</dl><a name="comment_anchor_169"></a>
<dl id="comment_169_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(169, '6');">引用</a> </span>
<a href="space-uid-1577.html" class="xi2 xw1" c="1">cl890305</a>
<span class="xg1 xw0">2012-2-6 09:27</span>
</dt>
<dd>来学习了</dd>
</dl><a name="comment_anchor_166"></a>
<dl id="comment_166_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(166, '6');">引用</a> </span>
<a href="space-uid-1589.html" class="xi2 xw1" c="1">mark006002</a>
<span class="xg1 xw0">2012-2-3 10:14</span>
</dt>
<dd>ＧＯＯＤ！又學到了一招～～</dd>
</dl><a name="comment_anchor_107"></a>
<dl id="comment_107_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(107, '6');">引用</a> </span>
<a href="space-uid-1162.html" class="xi2 xw1" c="1">TopWinStudio</a>
<span class="xg1 xw0">2011-12-30 11:44</span>
</dt>
<dd>刚看到这一节。顶。</dd>
</dl><a name="comment_anchor_96"></a>
<dl id="comment_96_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(96, '6');">引用</a> </span>
<a href="space-uid-1138.html" class="xi2 xw1" c="1">panzhiccp</a>
<span class="xg1 xw0">2011-12-28 10:38</span>
</dt>
<dd>我顶顶顶</dd>
</dl><a name="comment_anchor_70"></a>
<dl id="comment_70_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(70, '6');">引用</a> </span>
<a href="space-uid-1132.html" class="xi2 xw1" c="1">chichi1314</a>
<span class="xg1 xw0">2011-12-28 04:11</span>
</dt>
<dd>高手</dd>
</dl><a name="comment_anchor_59"></a>
<dl id="comment_59_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(59, '6');">引用</a> </span>
<a href="space-uid-1100.html" class="xi2 xw1" c="1">lucky</a>
<span class="xg1 xw0">2011-12-26 13:23</span>
</dt>
<dd>看着你这个 好像挺好的</dd>
</dl><a name="comment_anchor_47"></a>
<dl id="comment_47_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(47, '6');">引用</a> </span>
<a href="space-uid-1100.html" class="xi2 xw1" c="1">lucky</a>
<span class="xg1 xw0">2011-12-26 11:27</span>
</dt>
<dd>顶一下!!好东西呢 嘻嘻</dd>
</dl><a name="comment_anchor_8"></a>
<dl id="comment_8_li" class="ptm pbm bbda cl">
<dt class="mbm">
<span class="y xw0 xi2">
<a href="javascript:;" onclick="portal_comment_requote(8, '6');">引用</a> </span>
<a href="space-uid-51.html" class="xi2 xw1" c="1">apiter</a>
<span class="xg1 xw0">2011-10-30 18:15</span>
</dt>
<dd>咦，还没有人评论？</dd>
</dl><p class="ptm pbm"><a href="portal.php?mod=comment&id=6&idtype=aid" class="xi2">查看全部评论(<em id="_commentnum">20</em>)</a></p><form id="cform" name="cform" action="portal.php?mod=portalcp&ac=comment" method="post" autocomplete="off">
<div class="tedt">
<div class="area">
<textarea name="message" rows="3" class="pt" id="message" onkeydown="ctrlEnter(event, 'commentsubmit_btn');"></textarea>
</div>
</div>

<input type="hidden" name="portal_referer" value="portal.php?mod=view&aid=6#comment">
<input type="hidden" name="referer" value="portal.php?mod=view&aid=6#comment" />
<input type="hidden" name="id" value="0" />
<input type="hidden" name="idtype" value="" />
<input type="hidden" name="aid" value="6">
<input type="hidden" name="formhash" value="5ede86ec">
<input type="hidden" name="replysubmit" value="true">
<input type="hidden" name="commentsubmit" value="true" />
<p class="ptn"><button type="submit" name="commentsubmit_btn" id="commentsubmit_btn" value="true" class="pn"><strong>评论</strong></button></p>
</form>
</div>
</div>
<!--[diy=diycontentcomment]--><div id="diycontentcomment" class="area"></div><!--[/diy]-->


</div>
<div class="sd pph">


<div class="drag">
<!--[diy=diyrighttop]--><div id="diyrighttop" class="area"></div><!--[/diy]-->
</div>

<div class="bm">
<div class="bm_h cl">
<h2>相关分类</h2>
</div>
<div class="bm_c">
<ul class="xl xl2 cl"><li><a href="http://bbs.tairan.com/portal.php?mod=list&catid=11">[iTyran原创]OpenGL ES教程原创系列</a></li>
<li><a href="http://bbs.tairan.com/portal.php?mod=list&catid=2">[翻译]OpenGL ES for iPhone: Drawing a Circle</a></li>
<li><a href="http://bbs.tairan.com/portal.php?mod=list&catid=5">[子龙山人翻译]OpenGL ES2.0 – Iphone开发指引</a></li>
<li><a href="http://bbs.tairan.com/portal.php?mod=list&catid=3">从零开始学习OpenGL ES</a></li>
</ul>
</div>
</div>

<div class="drag">
<!--[diy=diy2]--><div id="diy2" class="area"></div><!--[/diy]-->
</div>


</div>
</div>

<script type="text/javascript">
var relatedlink = [];relatedlink[0] = {'sname':'翻译组', 'surl':'http://www.ityran.com/about'};
relatedlink[1] = {'sname':'泰然', 'surl':'http://ityran.com'};
relatedlinks('article_content');
</script>

<div class="wp mtn">
<!--[diy=diy3]--><div id="diy3" class="area"></div><!--[/diy]-->
</div>
<input type="hidden" id="portalview" value="1">	</div>




<script type="text/javascript">
_attachEvent(window, 'load', getForbiddenFormula, document);
function getForbiddenFormula() {
var toGetForbiddenFormulaFIds = function () {
ajaxget('plugin.php?id=cloudsearch&formhash=5ede86ec');
};
var a = document.body.getElementsByTagName('a');
for(var i = 0;i < a.length;i++){
if(a[i].getAttribute('sc')) {
a[i].setAttribute('mid', hash(a[i].href));
a[i].onmousedown = function() {toGetForbiddenFormulaFIds();};
}
}
var btn = document.body.getElementsByTagName('button');
for(var i = 0;i < btn.length;i++){
if(btn[i].getAttribute('sc')) {
btn[i].setAttribute('mid', hash(btn[i].id));
btn[i].onmousedown = function() {toGetForbiddenFormulaFIds();};
}
}
}
</script>


<div id="ft" class="wp cl">
<div id="flk" class="y">
<p>
<a href="forum.php?mobile=yes" >手机版</a><span class="pipe">|</span><a href="forum.php?mod=misc&action=showdarkroom" >小黑屋</a><span class="pipe">|</span><a href="archiver/" >Archiver</a><span class="pipe">|</span>
<strong><a href="http://bbs.tairan.com" target="_blank">泰然论坛</a></strong>
( <a href="http://www.miitbeian.gov.cn/" target="_blank">蜀ICP备13018980号-2</a> )

<script src="http://s11.cnzz.com/stat.php?id=3413370&web_id=3413370" language="JavaScript"></script>

</p>
<p class="xs0">
GMT+8, 2015-12-14 15:52
<span id="debuginfo">
, Processed in 0.024666 second(s), 15 queries
.

</span>
</p>
</div>
<div id="frt">
<p>Powered by <strong><a href="http://www.discuz.net" target="_blank">Discuz!</a></strong> <em>X3.2</em></p>
<p class="xs0">&copy; 2001-2013 <a href="http://www.comsenz.com" target="_blank">Comsenz Inc.</a></p>
</div>
</div>

<div id="scrolltop">

<span hidefocus="true"><a title="返回顶部" onclick="window.scrollTo('0','0')" class="scrolltopa" ><b>返回顶部</b></a></span>

</div>
<script type="text/javascript">_attachEvent(window, 'scroll', function () { showTopLink(); });checkBlind();</script>
			<div id="discuz_tips" style="display:none;"></div>
			<script type="text/javascript">
				var tipsinfo = '7267159|X3.2|0.6||0||0|7|1450079543|3271e66a184aa322b5b6bd594effae8f|2';
			</script>
			<script src="http://discuz.gtimg.cn/cloud/scripts/discuz_tips.js?v=1" type="text/javascript" charset="UTF-8"></script></body>
</html>
